﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using TimKen.BussLogic;
using TimKen.App;

namespace TimKen.Web
{
    public partial class Category : TimKen.App.WebPage
    {
        public PCategoryManager pcm = new PCategoryManager();
        public int categoryID = 0;
        public int brandid = 0;
        protected void Page_Load(object sender, EventArgs e)
        {

            if (string.IsNullOrEmpty(Request.QueryString["cid"]))
            {
                categoryID = 0;
            }
            else
                categoryID = int.Parse(Request.QueryString["cid"]);

            if (string.IsNullOrEmpty(Request.QueryString["brandid"]) || !TypeParse.IsNumeric(Request.QueryString["brandid"]))
            {
                brandid = 0;
            }
            else
                brandid = int.Parse(Request.QueryString["brandid"]);


            DataSet ds = pcm.GetChild(categoryID, LanguageID, brandid);

            if (ds.Tables[0].Rows.Count == 0)
            {
                Response.Redirect("POptionListSearch.aspx?CategoryID=" + categoryID + "&brandid=" + brandid);
            }
            else
            {
                ProductManager pm = new ProductManager();

                ///显示产品数量
                //  this.lbTotalProductCount.Text =pm.GetProductCountByCategoryID(categoryID).ToString();
                dlCategory.DataSource = ds;
                dlCategory.DataBind();
            }
        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("Category.aspx?" + Request.QueryString);
        }

        protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("Category2.aspx?" + Request.QueryString);
        }
    }
}